package com.ktvme.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ktvme.core.AbstractFlinkJobService;
import com.ktvme.core.JobInfo;
import com.ktvme.dto.FlinkJobConfigDTO;
import com.ktvme.entity.Cluster;
import com.ktvme.entity.FlinkJobConfig;
import com.ktvme.flink13.Flink1_13JobServiceImpl;
import com.ktvme.mapper.FlinkJobConfigMapper;
import com.ktvme.service.ClusterService;
import com.ktvme.service.FlinkJobConfigService;
import com.ktvme.vo.FlinkJobConfigVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ktvme.core.FlinkJobServiceFactory;

@Service
public class FlinkJobConfigServiceImpl extends ServiceImpl<FlinkJobConfigMapper, FlinkJobConfig> 
    implements FlinkJobConfigService {

    @Override
    public List<FlinkJobConfig> list() {
        return list();
    }

    @Override
    public FlinkJobConfig getById(Integer id) {
        return getById(id);
    }

    @Override
    public void save(FlinkJobConfigDTO configDTO) {
        FlinkJobConfig config = new FlinkJobConfig();
        BeanUtils.copyProperties(configDTO, config);
        
        config.setCreateTime(LocalDateTime.now());
        config.setUpdateTime(LocalDateTime.now());
        save(config);
    }

    @Override
    public void update(Integer id, FlinkJobConfigDTO configDTO) {
        FlinkJobConfig config = getById(id);
        if (config != null) {
            BeanUtils.copyProperties(configDTO, config);
            config.setUpdateTime(LocalDateTime.now());
            updateById(config);
        }
    }

    @Override
    public void delete(Integer id) {
        removeById(id);
    }
} 